package com.chrray.position.mygenerator;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyGeneratorStart {
	@Value("${generator.start.state}")
	private boolean generatorState;
	@Value("${base_url}")
	private String baseUrl;
	@Value("${java_base_url}")
	private String javaBaseUrl;
	@Value("${module_url}")
	private String moduleUrl;
	@Value("${spring.datasource.url}")
	private String connectionURL;
	@Value("${spring.datasource.username}")
	private String username;
	@Value("${spring.datasource.password}")
	private String password;
	@Value("${spring.datasource.driver-class-name}")
	private String driverClass;
	@Value("${public-key}")
	private String publicKey;
	@Value("${package_name}")
	private String packageName;
	@Value("${package_url}")
	private String packageUrl;
	@Value("${xml_base_url}")
	private String xmlBaseUrl;
	@Bean
	public String generatorStart() throws Exception {
		//解密密码
//		password=ConfigTools.decrypt(publicKey, password);
		if(generatorState){
			MybatisMysqlGenerator m=new MybatisMysqlGenerator(baseUrl,javaBaseUrl,moduleUrl,connectionURL,username,password,driverClass,packageName,packageUrl,xmlBaseUrl);
			//MybatisMysqlGeneratorOne m=new MybatisMysqlGeneratorOne();
			m.execute();
			return "生成代码完毕";
		}
		return "尚未开启代码生成器";
	}

}
